package com.heima.article.client;

import com.heima.model.article.dtos.ArticleDto;
import com.heima.model.article.dtos.AuthorDto;
import com.heima.model.media.dtos.WmNewsResultDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient("leadnews-article")
public interface ArticleFeign {

    /**
     * 保存作者
     */
    @PostMapping("/api/v1/author/save")
    public Integer saveAuthor(@RequestBody AuthorDto dto);

    /**
     * 根据apUserid 查询作者信息
     * @param apUserId
     * @return
     */
    @GetMapping("/api/v1/author/findByUserId/{id}")
    public AuthorDto findByApUserId(@PathVariable(name = "id") Integer apUserId);

    @PostMapping("/api/v1/article/save")
    Long saveArticle(@RequestBody WmNewsResultDTO wmNewDto);

    /**
     *
     * @param authorId
     * @return
     */
    @GetMapping("/api/v1/author/one/{id}")
    AuthorDto getAuthorById(@PathVariable("id") Integer authorId);

    /**
     * 查询所有未下架、未删除的文章列表
     */
    @GetMapping("/api/v1/article/findByPage")
    List<ArticleDto> findByPage(@RequestParam(name = "page") int page,
                                @RequestParam(name = "size") int size);

    /**
     * 基于文章id查询文章数据
     */
    @GetMapping("/api/v1/article/{id}")
    ArticleDto findArticleById(@PathVariable("id") Long articleId);
}
